//
//  ECUITVCell_Container.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/1/13.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECUITVCell_Container.h"
#import "ECUIVC_HomeCourse.h"
#define kHeight [UIScreen mainScreen].bounds.size.height - kNavHeight - 50

@interface ECUITVCell_Container() <UIScrollViewDelegate>

@end


@implementation ECUITVCell_Container
@synthesize scrollView = _scrollView;

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
}
- (void)addSubviews
{
    [super addSubviews];
    [self.contentView addSubview:self.scrollView];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    // 为了横向滑动的时候，外层的tableView不动
    if (!self.isSelectIndex) {
        if (scrollView == self.scrollView) {
            if (self.delegate &&
                [self.delegate respondsToSelector:@selector(mmtdOptionalScrollViewDidScroll:)]) {
                [self.delegate mmtdOptionalScrollViewDidScroll:scrollView];
            }
        }
    }
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    self.isSelectIndex = NO;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    if (scrollView == self.scrollView) {
        if (self.delegate &&
            [self.delegate respondsToSelector:@selector(mmtdOptionalScrollViewDidEndDecelerating:)]) {
            [self.delegate mmtdOptionalScrollViewDidEndDecelerating:scrollView];
        }
    }
}

#pragma mark - Init Views

- (UIScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavHeight - kTabbarHeight )];
        _scrollView.delegate = self;
        _scrollView.pagingEnabled = YES;
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width * 3, _scrollView.frame.size.height);
    }
    return _scrollView;
}

- (void)setObjectCanScroll:(BOOL)objectCanScroll {
    _objectCanScroll = objectCanScroll;
//    self.oneVC.vcCanScroll = objectCanScroll;
//    self.twoVC.vcCanScroll = objectCanScroll;
//    self.threeVC.vcCanScroll = objectCanScroll;
    
//    if (!objectCanScroll) {
//        [self.oneVC.tableView setContentOffset:CGPointZero animated:NO];
//        [self.twoVC.tableView setContentOffset:CGPointZero animated:NO];
//        [self.threeVC.tableView setContentOffset:CGPointZero animated:NO];
//    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
